package com.sx.gongzhong.adapter;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;

import com.sx.gongzhong.R;
import com.sx.gongzhong.model.LegalAdviceTypeBean;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.List;

/**
 * Created by admin on 2018/1/12.
 */

public class LegalTypeAdapter  extends CommonAdapter<LegalAdviceTypeBean> {

    LegalTypeCallback mCallback;

    public LegalTypeAdapter(Context context, int layoutId, List<LegalAdviceTypeBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder viewHolder, final LegalAdviceTypeBean item, int position) {
        CheckBox checkBox = viewHolder.getView(R.id.checkbox);
        checkBox.setText(item.getName());
        checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCallback != null) {
                    mCallback.getData(item);
                }
            }
        });
    }

    /**
     * 定义一个接口
     */
    public interface LegalTypeCallback {
        void getData(LegalAdviceTypeBean typesBean);
    }

    /*接口回调*/
    public void getLegalType(LegalTypeCallback callback) {
        mCallback = callback;
    }
}
